package edu.hunau.cxb19.oop.class11.hk;

/**
 * 扑克牌
 * 
 * @author hb
 *
 *         2020-03-03 14:45:27
 */
public class Poker {
	/**
	 * 表示花色:每个扑克的实例都有自己的花色 0表示 ♠，1表示♥，2表示♣，3表示♦
	 */
	private int suit;

	/**
	 * 表示点数:每个扑克的实例都有自己的点数
	 * 0表示点数3,1表示点数4,....,8表示J,9表示Q,10表示K,11表示A,12表示2，13表示小王,14表示大王
	 * 
	 * 
	 */
	private int rank;

	/**
	 * 重写toString方法返回对象的内容
	 */
	@Override
	public String toString() {
		return SUIT_DESC[this.suit] + RANK_DESC[this.rank];
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;
		// 如果对象就是当前的引用
		if (obj == this) {
			return true;
		}
		// 如果对象的引用实现运行时的类型为当前类
		if (obj instanceof Poker) {
			Poker other = (Poker) obj;
			// 通过比较的细节判定内容是否相同
			return this.suit == other.suit && this.rank == other.rank;
		}
		return false;
	}

	@Override
	public int hashCode() {
		return this.suit + this.rank;
	}

	/**
	 * 使用常量描述花色:无论有多少扑克的实例，扑克的花色只有四种
	 */
	public static final int SUIT_HEITAO = 0;
	public static final int SUIT_HONTAO = 1;
	public static final int SUIT_MEIHUA = 2;
	public static final int SUIT_FANGKU = 3;
	public static final int SUIT_KING = 4;

	private static final String[] SUIT_DESC = { "♠", "♥", "♣", "♦", "" };

	/**
	 * 使用常量描述点数：无论有多少扑克的实例，扑克的点数是可以穷举的
	 */
	public static final int RANK_3 = 0;
	public static final int RANK_4 = 1;
	public static final int RANK_5 = 2;
	public static final int RANK_6 = 3;
	public static final int RANK_7 = 4;
	public static final int RANK_8 = 5;
	public static final int RANK_9 = 6;
	public static final int RANK_10 = 7;
	public static final int RANK_J = 8;
	public static final int RANK_Q = 9;
	public static final int RANK_K = 10;
	public static final int RANK_A = 11;
	public static final int RANK_2 = 12;

	public static final int SMALL = 13;
	public static final int BIG = 14;

	private static final String[] RANK_DESC = { "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A", "2", "小王",
			"大王" };

	/**
	 * 将当前扑克的内容采用字符串的形式输出
	 * 
	 * @return
	 */
//	public String print() {
//		return SUIT_DESC[this.suit]+RANK_DESC[this.rank];
//	}

	public Poker() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @param suit
	 * @param rank
	 */
	public Poker(int suit, int rank) {
		super();
		this.suit = suit;
		this.rank = rank;
	}

	/**
	 * @return the suit
	 */
	public int getSuit() {
		return suit;
	}

	/**
	 * @param suit the suit to set
	 */
	public void setSuit(int suit) {
		this.suit = suit;
	}

	/**
	 * @return the rank
	 */
	public int getRank() {
		return rank;
	}

	/**
	 * @param rank the rank to set
	 */
	public void setRank(int rank) {
		this.rank = rank;
	}

}
